package com.example.recordingpen_datacollection.AIBDText;

import java.util.List;
import java.util.Map;

public class CSAIKer {

    /**
     * 测试服务
     * @return
     */
    public static List<AIKerDuo.Server> TestSetver(List<AIKerDuo.Server> serverParList){
        AIKerDuo.Server serverSigo = null;
        /**
         * 查询标记为1的
         */
        for (AIKerDuo.Server server : serverParList) {
            if(server.getSign() ==1){
                serverSigo = server;
                break;
            }
        }

        int sign = 0;
        for (int i = 0; i < 13; i++) {


            //更改标记
            for (int j = 0; j < serverParList.size() && sign==3; j++) {
                AIKerDuo.Server server = serverParList.get(j);
                System.out.println("j->" + j);
                System.out.println(server.getSign() ==1);
                //修改
                if(server.getSign() ==1){
                    server.setSign(0);
//                    map.put("N："+j,server);
                    serverParList.remove(j);
                    serverParList.add(j,server);
                    System.out.println("(serverParList.size()>(j+1))->"+(serverParList.size()>(j+1))+": j+1: " +(j+1));
//                    System.out.println("map.containsKey(\"N：\"+i+1)->"+map.containsKey("N："+(j+1)) +": j+1" +(j));
                    if(serverParList.size()>(j+1)){
                        AIKerDuo.Server server2 = serverParList.get(j);
                        server2.setSign(0);
                        serverParList.remove(j);
                        serverParList.add((j),server2);


                        AIKerDuo.Server server1 = serverParList.get(j+1);
                        server1.setSign(1);
                        serverParList.remove(j+1);
                        serverParList.add((j+1),server1);

                        serverSigo = server1;
                    } else {
                        AIKerDuo.Server server2 = serverParList.get(j);
                        server2.setSign(0);
                        serverParList.remove(j);
                        serverParList.add((j),server2);

                        AIKerDuo.Server server1 = serverParList.get(0);
                        server1.setSign(1);
                        serverParList.remove(0);
                        serverParList.add(0,server1);
                        serverSigo = server1;
                    }
                    System.out.println("sign = 0;");
                    sign = 0;
                    break;
                }

            }
            sign++;
            System.out.println("sign++ ："+sign);
            serverSigo.setTime(serverSigo.getTime()+1);
        }
        return serverParList;
    }
}
